'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema,
    baseController = require('../../../Base/server/controllers/BaseDoc.js');

//条码装配关系
var newModel = baseController.getBaseDocFields();
//条码主档
newModel.BarcodeMaster = {
    type: Schema.ObjectId,
    ref: 'BarcodeMaster'
};
//装配条码
newModel.AssemblyBarcode = {
    type: Schema.ObjectId,
    ref: 'BarcodeMaster'
};

//类型 0: 装配 1: 容器
newModel.AssemblyType = {
    type: Number
};

//采集时间
newModel.CollectDateTime = {
    type: Date,
    default: Date.now
};

var newSchema = new Schema(newModel);
newSchema.index({BarcodeMaster: 1, AssemblyBarcode: 1}, {"unique": true});

mongoose.model('AssemblyRelation', newSchema, 'AssemblyRelation');
